<?php


namespace app\seller\controller;

use think\Db;
use think\Config;

class Index extends Base
{
    public function index()
    {
        $fangjianid = $this->fangjianIds();
        $today = Db::name('order')
            ->field('count(id) as count,sum(price) as price')
            ->whereTime('createtime', 'today')
            ->where("fangjian_id", "in", $fangjianid)
            ->where('status', "in", "1,2,3,5,6")
            ->find();
        $day7 = Db::name('order')
            ->whereTime('createtime', 'between', [date('Y-m-d 00:00:00', strtotime("-7 day")), date('Y-m-d 23:59:59')])
            ->where("fangjian_id", "in", $fangjianid)
            ->where('status', "in", "1,2,3,5,6")
            ->count();
        $month = Db::name('order')
            ->whereTime('createtime', 'month')
            ->where("fangjian_id", "in", $fangjianid)
            ->where('status', "in", "1,2,3,5,6")
            ->count();
        $allOrder = Db::name('order')
            ->where("fangjian_id", "in", $fangjianid)
            ->where('status', "in", "1,2,3,5,6")
            ->count();
        return $this->success('获取成功', [
            'today_price' => $today['price'] ? $today['price'] : 0,
            'today_count' => $today['count'] ? $today['count'] : 0,
            'all_order' => $allOrder ? $allOrder : 0,
            'day7' => $day7 ? $day7 : 0,
            'month' => $month ? $month : 0,
            'name' => $this->shop['name'],
        ]);

    }
}
